{% extends "base.html" %}

{% block content %}
<div class="container">
    <h2>年份管理</h2>
    
    <!-- 添加年份表单 -->
    <div class="card mb-4">
        <div class="card-body">
            <form action="{{ url_for('add_year') }}" method="POST" class="row g-3 align-items-end">
                <div class="col-auto">
                    <label for="year" class="form-label">添加新年份</label>
                    <input type="number" class="form-control" id="year" name="year" required min="1900" max="2100">
                </div>
                <div class="col-auto">
                    <button type="submit" class="btn btn-primary">添加</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 年份列表 -->
    <div class="card">
        <div class="card-body">
            <div class="table-responsive">
                <table class="table">
                    <thead>
                        <tr>
                            <th>年份</th>
                            <th>状态</th>
                            <th>操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        {% for year in years %}
                        <tr>
                            <td>{{ year.year }}年</td>
                            <td>
                                {% if year.is_active %}
                                <span class="badge bg-success">启用</span>
                                {% else %}
                                <span class="badge bg-danger">禁用</span>
                                {% endif %}
                            </td>
                            <td>
                                <form action="{{ url_for('toggle_year', year_id=year.id) }}" method="POST" style="display: inline;">
                                    <button type="submit" class="btn btn-warning btn-sm">
                                        {% if year.is_active %}禁用{% else %}启用{% endif %}
                                    </button>
                                </form>
                            </td>
                        </tr>
                        {% endfor %}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{% endblock %} 